<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->title}</title>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="wrapper">
  <div class="title shadow titleBg">
    <table width="100%" border="0" cellspacing="1">
      <tr>
        <td><h1> {:$i->title} <span>[<a href="{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/add">添加栏目</a>] [<a href="#" class="helpTip" title="可以上下拖动栏目名称进行排序">?</a>]</span></h1></td>
      </tr>
    </table>
  </div>
  <div class="content shadow">
    <table width="100%" border="0" cellspacing="1">
      <tr class="titleBg">
        <th scope="col">#ID</th>
        <th scope="col">选择</th>
        <th class="textL" scope="col">栏目名称</th>
        <th scope="col">类型</th>
        <th scope="col">访问</th>
        <th scope="col">隐藏</th>
        <th scope="col">操作</th>
      </tr>
      <tbody class="main">
{:foreach item=item from=$i->lists}<tr>
        <td>{:$item->id}</td>
        <td><input name="selected[]" type="checkbox" value="{:$item->id}" class="noBorder" /></td>
        <td class="textL">
        {:$item->name}
        {:if $item->alias != '' && $item->type != '0'}
        	({:$item->alias})
        {:/if}</td>
        <td>
        {:if $item->type == 1}
        	{:$item->channelName}列表
        {:elseif $item->type == 2}
        	栏目封面
        {:else}
        	任意链接
        {:/if}</td>
        <td>
        {:if $item->type == '0'}
        	跳转
        {:elseif $item->visit == 1}
        	静态
        {:elseif $item->visit == 2}
        	动态
        {:else}
        	自动
        {:/if}
        </td>
        <td>
        {:if $item->isHidden}
        	是
        {:else}
        	否
        {:/if}</td>
        <td>
        {:if $item->type == 1}
        	<a href="{:$smarty.const.BOOT_URL}/{:$i->c}/archive/lists/0/{:$item->id}">管理文档</a> | 
        	<a target="_blank" href="{:$smarty.const.ROOT_DIR}/data.php/category/{:$item->id}">预览</a> | 
        {:elseif $item->type == 2}
        	<a href="{:$smarty.const.BOOT_URL}/{:$i->c}/archive/lists/0/{:$item->id}">管理文档</a> | 
        	<a target="_blank" href="{:$smarty.const.ROOT_DIR}/data.php/category/{:$item->id}">预览</a> | 
        {:else}
        	<a target="_blank" href="{:$item->link}">预览</a> | 
        {:/if}
        <a href="{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/mod/{:$item->id}">修改</a> | <a onclick="del({:$item->id});" href="#@">删除</a></td>
      </tr>{:/foreach}
</tbody>
      <tr>
        <td colspan="7" class="lightGreyBg textL"> <a href="#@" onclick="selAll('selected[]');">全选</a> | <a href="#@" onclick="selAnti('selected[]');">反选</a> | <a href="#@" onclick="del(0);">删除</a></td>
      </tr>
    </table>
  </div>
</div>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/tooltip.css" rel="stylesheet" type="text/css" />
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/ui.all.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.core.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.draggable.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.resizable.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.dialog.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.sortable.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.tooltip.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/common.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function() {
	$(".helpTip").tooltip({cssClass:"tooltip", xOffset:30, opacity:5});
});

function del(id)
{
	var ids='';
	
	if(id == 0)
	{
		$("input:checked[name='selected[]']").each(function(i){
			ids+=this.value+',';
		});
		ids = ids.substr(0,ids.length-1);
	}
	else if(id > 0)
	{
		ids = id;
	}
	
	if(ids.length==0)
	{
		alert('您还没有选中要删除的记录');
		return false;
	}
	
	if(confirm('删除栏目会同时删除相关的子栏目及相关栏目下的全部文档，确定要删除ID为'+ids+'的栏目?'))
	{
		getDialog('{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/del/'+ids, '{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/lists/-1');
	}
	
	return false;
}

function order()
{
	var ids = '';
	$("input[name='selected[]']").each(function(){
		if(ids == '')
		{
			ids=this.value;
		}
		else
		{
			ids+=','+this.value;
		}
	});
							
	getDialog('{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/ordering/'+ids);
	
	return false;
}

$(function() {
	$(".main")
	.sortable({
		connectWith: '.main',
		update: function(event, ui) { order(); },
		axis: 'y',
		cursor: 'move' ,
		delay: 100,
		opacity: 0.9
	});
});
</script>
</body>
</html>
